/**
 * Created by Administrator on 14-4-17.
 */
function customplayer(){
    this. name;
    this. introduce;
    this. run;
}
var tem=new customplayer();
tem.name="attack";
console.log(map);
tem.introduce='<p>'+map.introduce+'</p> <button type="button" onclick="map.player.run=playerlist[0].run;showScreen();">choose</button> ';
tem.run=function(){
    mes.begin();
    var p1=mes.getPosition('enemy');
    var p2=mes.getPosition('player');
    var dx=p1.x-p2.x;var dy=p1.y-p2.y;
    var angle=Math.atan2(dy,dx);
    var a1=mes.getAngular('player');
    this.turn(angle-a1);
     this.attack();
    mes.end();
}
var playerlist=Array();
playerlist[0]=tem;
playerlist[1]=new customplayer();
playerlist[1].name="rush";
playerlist[1].run=function(){
    mes.begin();
    var p1=mes.getPosition('enemy');
    var p2=mes.getPosition('player');
    var dx=p1.x-p2.x;var dy=p1.y-p2.y;
    var angle=Math.atan2(dy,dx);
    var a1=mes.getAngular('player');
    this.turn(angle-a1);
    this.goahead(5);
    // this.attack();
    mes.end();
}
playerlist[1].introduce=map.introduce+' <button type="button" onclick="map.player.run=playerlist[1].run;showScreen();">choose</button> ';

for(var i=0;i<playerlist.length;i++){
    function mclick(a){
        intro.innerHTML=playerlist[a].introduce+ '<button type="button" class="overlay-close" onclick="showScreen();">Close</button>';
        showScreen();
    }
    items+=' <section style="float: left ;" onclick=" mclick('+i+')">  <p><button class="class-trigger" type="button"> '
        +playerlist[i].name
        +'</button></p>   </section>';
}
container.innerHTML=items;